﻿using System;
using System.Data;
using WAF.EntityFramework;

namespace TraderClient.Models
{
    /// <summary>
    /// 合约信息
    /// </summary>
    public class Instrument : Entity
    {
        [EntityField(1,isNullable:false, isUnique:true, isDisplay:true, label:"合约代码")]
        public string InstrumentID { get; set; }

        [EntityField(2, label: "交易所代码")]
        public string ExchangeID { get; set; }

        [EntityField(3, label: "合约名称")]
        public string InstrumentName { get; set; }

        [EntityField(4, label: "合约在交易所的代码")]
        public string ExchangeInstID { get; set; }

        [EntityField(5, label: "产品代码")]
        public string ProductID { get; set; }

        [EntityField(6, dbType: DbType.SByte, label: "产品类型")]
        public sbyte ProductClass { get; set; }

        [EntityField(7, label: "交割年份")]
        public int DeliveryYear { get; set; }

        [EntityField(8, label: "交割月")]
        public int DeliveryMonth { get; set; }

        [EntityField(9, label: "市价单最大下单量")]
        public int MaxMarketOrderVolume { get; set; }

        [EntityField(10, label: "市价单最小下单量")]
        public int MinMarketOrderVolume { get; set; }

        [EntityField(11, label: "限价单最大下单量")]
        public int MaxLimitOrderVolume { get; set; }

        [EntityField(12, label: "限价单最小下单量")]
        public int MinLimitOrderVolume { get; set; }

        [EntityField(13, label: "合约数量乘数")]
        public int VolumeMultiple { get; set; }

        [EntityField(14, label: "最小变动价位")]
        public double PriceTick { get; set; }

        [EntityField(15, label: "创建日")]
        public string CreateDate { get; set; }

        [EntityField(16, label: "上市日")]
        public string OpenDate { get; set; }

        [EntityField(17, label: "到期日")]
        public string ExpireDate { get; set; }

        [EntityField(18, label: "开始交割日")]
        public string StartDelivDate { get; set; }

        [EntityField(19, label: "结束交割日")]
        public string EndDelivDate { get; set; }

        [EntityField(20, dbType: DbType.SByte, label: "合约生命周期状态")]
        public sbyte InstLifePhase { get; set; }

        [EntityField(21, label: "当前是否交易")]
        public int IsTrading { get; set; }

        [EntityField(22, dbType: DbType.SByte, label: "持仓类型")]
        public sbyte PositionType { get; set; }

        [EntityField(23, dbType: DbType.SByte, label: "持仓日期类型")]
        public sbyte PositionDateType { get; set; }

        [EntityField(24, label: "多头保证金率")]
        public double LongMarginRatio { get; set; }

        [EntityField(25, label: "空头保证金率")]
        public double ShortMarginRatio { get; set; }
    }

    /// <summary>
    /// 要显示的合约
    /// </summary>
    public class DisplayInstruments : Entity
    {
        [EntityField(1, isNullable: false, isUnique: true, isDisplay: true, label: "合约代码")]
        public string InstrumentID { get; set; }
    }

    /// <summary>
    /// CTP账户
    /// </summary>
    public class CtpAccount : Entity
    {
        [EntityField(1, isUnique: true, isNullable: false, label: "账号")]
        public string AccountID { get; set; }

        [EntityField(2, label: "密码")]
        public string Password { get; set; }

        [EntityField(3, label: "经纪商", refTable: "Broker", refLableField: "BrokerName")]
        public string BrokerID { get; set; }

        [EntityField(4, label: "地区", refTable: "FrontAddressGroup", refLableField: "Name")]
        public long GroupID { get; set; }

        [EntityField(5, label: "默认", refTable: "YesNo", refLableField: "Name")]
        public long IsDefault { get; set; }
    }
}

/*
namespace WAF.Data.EntityClass
{
    public class Account : Entity
    {
        [EntityField(1, isUnique:true, isNullable:false, label:"账号")]
        public string AccountID { get; set; }

        [EntityField(2, label: "密码")]
        public string Password { get; set; }

        [EntityField(3, false, false, true, true, DbType.String, 10, "经纪商", "Broker", "BrokerID", "BrokerName")]
        public string BrokerID { get; set; }

        [EntityField(4, false, false, true, true, DbType.Int64, 0, "地区", "FrontAddressGroup", "rowid", "Name")]
        public long GroupID { get; set; }

        [EntityField(5, false, false, true, true, DbType.Int64, 0, "默认", "YesNo", "rowid", "Name")]
        public long IsDefault { get; set; }

    }

    public class Broker : WAF.Data.EntityBase
    {
        [EntityField(0, true, true, true, false, DbType.Int64, 0, "id")]
        public long rowid { get; set; }

        [EntityField(1, false, true, true, false, DbType.String, 10, "经纪商ID")]
        public string BrokerID { get; set; }

        [EntityField(2, false, false, true, false, DbType.String, 100, "经纪商名称")]
        public string BrokerName { get; set; }

        [EntityField(3, false, false, false, false, DbType.String, 1000, "备注")]
        public string Remark { get; set; }

    }

    public class FrontAddress : WAF.Data.EntityBase
    {
        [EntityField(0, true, true, true, false, DbType.Int64, 0, "id")]
        public long rowid { get; set; }

        [EntityField(1, false, true, true, false, DbType.String, 100, "前置机地址")]
        public string AddressURL { get; set; }

        [EntityField(2, false, false, true, true, DbType.String, 10, "经纪商", "Broker", "BrokerID", "BrokerName")]
        public string BrokerID { get; set; }

        [EntityField(3, false, false, true, true, DbType.Int64, 0, "地区", "FrontAddressGroup", "rowid", "Name")]
        public long GroupID { get; set; }

        [EntityField(4, false, false, true, true, DbType.Int64, 0, "类型", "FrontAddressType", "rowid", "Name")]
        public long TypeID { get; set; }

    }

    public class FrontAddressGroup : WAF.Data.EntityBase
    {
        [EntityField(0, true, true, true, false, DbType.Int64, 0, "id")]
        public long rowid { get; set; }

        [EntityField(1, false, false, true, false, DbType.String, 10, "地区")]
        public string Name { get; set; }

    }

    public class FrontAddressType : WAF.Data.EntityBase
    {
        [EntityField(0, true, true, true, false, DbType.Int64, 0, "id")]
        public long rowid { get; set; }

        [EntityField(1, false, false, true, false, DbType.String, 50, "类型")]
        public string Name { get; set; }

    }

    public class Instrument : WAF.Data.EntityBase
    {
        [EntityField(0, true, true, true, false, DbType.Int64, 0, "id")]
        public long rowid { get; set; }

        [EntityField(1, false, true, true, false, DbType.String, 30, "合约代码")]
        public string InstrumentID { get; set; }

        [EntityField(2, false, false, false, false, DbType.String, 8, "交易所代码")]
        public string ExchangeID { get; set; }

        [EntityField(3, false, false, false, false, DbType.String, 20, "合约名称")]
        public string InstrumentName { get; set; }

        [EntityField(4, false, false, false, false, DbType.String, 30, "合约在交易所的代码")]
        public string ExchangeInstID { get; set; }

        [EntityField(5, false, false, false, false, DbType.String, 30, "产品代码")]
        public string ProductID { get; set; }

        [EntityField(6, false, false, false, false, DbType.String, 1, "产品类型")]
        public string ProductClass { get; set; }

        [EntityField(7, false, false, false, false, DbType.Int32, 0, "交割年份")]
        public int DeliveryYear { get; set; }

        [EntityField(8, false, false, false, false, DbType.Int32, 0, "交割月")]
        public int DeliveryMonth { get; set; }

        [EntityField(9, false, false, false, false, DbType.Int32, 0, "市价单最大下单量")]
        public int MaxMarketOrderVolume { get; set; }

        [EntityField(10, false, false, false, false, DbType.Int32, 0, "市价单最小下单量")]
        public int MinMarketOrderVolume { get; set; }

        [EntityField(11, false, false, false, false, DbType.Int32, 0, "限价单最大下单量")]
        public int MaxLimitOrderVolume { get; set; }

        [EntityField(12, false, false, false, false, DbType.Int32, 0, "限价单最小下单量")]
        public int MinLimitOrderVolume { get; set; }

        [EntityField(13, false, false, false, false, DbType.Int32, 0, "合约数量乘数")]
        public int VolumeMultiple { get; set; }

        [EntityField(14, false, false, false, false, DbType.Double, 0, "最小变动价位")]
        public double PriceTick { get; set; }

        [EntityField(15, false, false, false, false, DbType.String, 8, "创建日")]
        public string CreateDate { get; set; }

        [EntityField(16, false, false, false, false, DbType.String, 8, "上市日")]
        public string OpenDate { get; set; }

        [EntityField(17, false, false, false, false, DbType.String, 8, "到期日")]
        public string ExpireDate { get; set; }

        [EntityField(18, false, false, false, false, DbType.String, 8, "开始交割日")]
        public string StartDelivDate { get; set; }

        [EntityField(19, false, false, false, false, DbType.String, 8, "结束交割日")]
        public string EndDelivDate { get; set; }

        [EntityField(20, false, false, false, false, DbType.String, 1, "合约生命周期状态")]
        public string InstLifePhase { get; set; }

        [EntityField(21, false, false, false, false, DbType.Int32, 0, "当前是否交易")]
        public int IsTrading { get; set; }

        [EntityField(22, false, false, false, false, DbType.String, 1, "持仓类型")]
        public string PositionType { get; set; }

        [EntityField(23, false, false, false, false, DbType.String, 1, "持仓日期类型")]
        public string PositionDateType { get; set; }

        [EntityField(24, false, false, false, false, DbType.Double, 0, "多头保证金率")]
        public double LongMarginRatio { get; set; }

        [EntityField(25, false, false, false, false, DbType.Double, 0, "空头保证金率")]
        public double ShortMarginRatio { get; set; }

    }

    public class YesNo : WAF.Data.EntityBase
    {
        [EntityField(0, true, true, true, false, DbType.Int64, 0, "id")]
        public long rowid { get; set; }

        [EntityField(1, false, false, true, false, DbType.String, 2, "是否")]
        public string Name { get; set; }

    }

}
*/